<template>
	<div>
		<div style="margin-bottom: 1.25rem;cursor: pointer;" @click="work()">作业文件夹><span style="color: #b6b6b6;">{{phone.taskDireName}}</span></div>

		<el-table :data="tableData" tooltip-effect="dark" style="width: 100%;overflow: auto;height: 100vh;"
		 :header-cell-style="{'background-color': '#f2f4f7'}" :cell-style="{padding:'20px 0'}">
			<el-table-column label="标号" type="index" :index="indexMethod" width="200px
			">
			</el-table-column>
			<el-table-column label="文件夹" prop="taskName">
			</el-table-column>
			<el-table-column prop="createTime" label="创建时间">
			</el-table-column>
			<el-table-column prop="address" label="操作" show-overflow-tooltip>
				<template slot-scope="scope">
					<!-- {{ scope.row.date }} -->
					<el-button style="border:#03d3bd 1px solid;color: black;" 　size="mini" @click="fabu(scope.row.id)">发布</el-button>
					<!-- <el-button style="border:#ffab03 1px solid;color: black;" @click="check(scope.$index,scope.row)" size="mini">编辑</el-button> -->
					<el-button style="border: #ff4949 1px solid;color: black;" 　size="mini" @click="deleteTask(scope.row.id)">删除</el-button>
					<!-- <el-link type="primary" style="margin-left: 0.875rem;">发布</el-link>
				<el-link type="success" style="margin-left: 0.875rem;">编辑</el-link>
				<el-link type="danger" style="margin-left: 0.875rem;">删除</el-link> -->
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	import {
		HttpManager
	} from "../../../../request/Teacher.js"
	export default {

		data() {
			return {
				tableData: [],
				multipleSelection: [],
				// 表单数据
				formData: {
					// 上级文件夹id，默认全部文件最上层为0
					id: 0,
					// 搜索框内容
					search: '',
					// 是否逆序
					reverse: false
				},
				newClassMask: false,
				addstudent: false,
				activeName: 'first',
				courseId: window.localStorage.getItem("ClassId"),

			}

		},
		props: {
			phone: Object,
			UserId: String
		},
		created() {
			this.getTaskByCourseIdAndPhone();
		},
		methods: {
			// 获取文件列表
			async getFiles() {
				// 清空被选中文件id列表
				this.checkedList = []
				console.log('获取文件列表')
				// params参数：文件夹id、搜索的值、是否逆序
				// this.files = await axios.get('/files', { params: this.formData })
			},
			handleSelectionChange() {

			},
			handleClose() {
				this.addstudent = false
			},
			handleClick(tab, event) {
				console.log(tab, event);
			},
			work() {
				this.$emit("child2-event")
			},
			//根据课程id跟教师手机号获取教师发布的任务
			getTaskByCourseIdAndPhone() {
				if (this.UserId) {
					this.courseId = this.UserId;
				};

				HttpManager.getTaskByCourseIdAndPhone(this.courseId, this.phone.phone).then(e => {
					console.log(e);
					this.tableData = e.data.data;
				})
			},
			indexMethod(index) {
				return index + 1;
			},
			fabu(id){
				localStorage.setItem("TestId",id);
				this.$router.push('/Releasejob')
			},
			deleteTask(id)
			{
				HttpManager.deleteTask([id]).then(e=>{
					console.log(e);
					this.getTaskByCourseIdAndPhone();
				})
			}

		}


	}
</script>


<style>
</style>
